package hust.ioic.oa.service.impl;



import java.util.List;

import javax.annotation.Resource;

import hust.ioic.oa.service.KnowTypeService;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import hust.ioic.oa.base.BaseDao;
import hust.ioic.oa.base.BaseDaoImpl;
import hust.ioic.oa.domain.Department;
import hust.ioic.oa.domain.KnowType;

@Service
@Transactional
@SuppressWarnings("unchecked")
public class KnowTypeServiceImpl extends BaseDaoImpl<KnowType> implements KnowTypeService{

	@Override
	public List<KnowType> findTopList() {
		return getSession().createQuery(//
				"FROM KnowType d WHERE d.parent IS NULL")//
				.list();
	}

	@Override
	public List<KnowType> findChildren(Integer parentId) {
		return getSession()//
				.createQuery("FROM KnowType a WHERE a.parent.id=? ")//
				.setParameter(0, parentId)
				.list();
	}


	@Override
	public List<String> findAllNames() {
		
		return getSession()
				.createQuery("SELECT  a.name FROM KnowType a   ORDER BY a.id ASC")
				.list();
	}

}
